"""
热点平台配置模块
定义56个平台的数据获取配置
"""

from typing import Dict, Any


class PlatformConfig:
    """平台配置管理器"""
    
    PLATFORMS: Dict[str, Dict[str, Any]] = {
        # 社交媒体类
        "zhihu": {
            "name": "知乎",
            "type": "热榜",
            "description": "知乎实时热榜",
            "base_url": "https://www.zhihu.com",
            "api_url": "https://api.zhihu.com/topstory/hot-lists/total",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
            },
            "params": {"limit": 50},
            "cookies": {"ZHIHU_COOKIE": "知乎Cookie"}
        },
        
        "bilibili": {
            "name": "哔哩哔哩",
            "type": "排行榜",
            "description": "B站全站排行榜",
            "base_url": "https://www.bilibili.com",
            "api_url": "https://api.bilibili.com/x/web-interface/ranking/v2",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
                "Referer": "https://www.bilibili.com"
            },
            "params": {"rid": 0, "type": "all"},
            "categories": {
                "0": "全站",
                "1": "动画",
                "3": "音乐",
                "4": "游戏",
                "5": "娱乐",
                "119": "鬼畜",
                "129": "舞蹈",
                "155": "时尚",
                "160": "生活",
                "168": "国创相关",
                "181": "影视",
                "188": "科技"
            }
        },
        
        "weibo": {
            "name": "微博",
            "type": "热搜",
            "description": "微博实时热搜榜",
            "base_url": "https://s.weibo.com",
            "api_url": "https://weibo.com/ajax/side/hotSearch",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            },
            "cookies": {"WEIBO_COOKIE": "微博Cookie"}
        },
        
        "douyin": {
            "name": "抖音",
            "type": "热榜",
            "description": "抖音热点榜",
            "base_url": "https://www.douyin.com",
            "api_url": "https://www.douyin.com/aweme/v1/web/hot/search/list",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        # 新闻资讯类
        "toutiao": {
            "name": "今日头条",
            "type": "热榜",
            "description": "今日头条热点新闻",
            "base_url": "https://www.toutiao.com",
            "api_url": "https://www.toutiao.com/hot-event/hot-board",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "qq-news": {
            "name": "腾讯新闻",
            "type": "热点",
            "description": "腾讯新闻热点",
            "base_url": "https://news.qq.com",
            "api_url": "https://r.inews.qq.com/gw/event/hot",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "netease-news": {
            "name": "网易新闻",
            "type": "热点",
            "description": "网易新闻热点",
            "base_url": "https://news.163.com",
            "api_url": "https://news.163.com/special/0001386F/rank_whole",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "sina-news": {
            "name": "新浪新闻",
            "type": "热点",
            "description": "新浪新闻热点",
            "base_url": "https://news.sina.com.cn",
            "api_url": "https://feed.sina.com.cn/api/roll/get",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        # 科技类
        "36kr": {
            "name": "36氪",
            "type": "热榜",
            "description": "36氪科技热榜",
            "base_url": "https://36kr.com",
            "api_url": "https://36kr.com/api/search-column/mainsite",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "juejin": {
            "name": "掘金",
            "type": "热榜",
            "description": "掘金技术热榜",
            "base_url": "https://juejin.cn",
            "api_url": "https://api.juejin.cn/content_api/v1/article/query_list",
            "method": "POST",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
                "Content-Type": "application/json"
            }
        },
        
        "csdn": {
            "name": "CSDN",
            "type": "热榜",
            "description": "CSDN技术热榜",
            "base_url": "https://blog.csdn.net",
            "api_url": "https://blog.csdn.net/phoenix/web/blog/hot-rank",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "github": {
            "name": "GitHub",
            "type": "趋势",
            "description": "GitHub趋势项目",
            "base_url": "https://github.com",
            "api_url": "https://api.github.com/search/repositories",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
                "Accept": "application/vnd.github.v3+json"
            },
            "params": {"q": "stars:>1000", "sort": "stars", "order": "desc"}
        },
        
        # 社区论坛类
        "v2ex": {
            "name": "V2EX",
            "type": "热榜",
            "description": "V2EX热门话题",
            "base_url": "https://www.v2ex.com",
            "api_url": "https://www.v2ex.com/api/topics/hot.json",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "tieba": {
            "name": "百度贴吧",
            "type": "热榜",
            "description": "百度贴吧热门",
            "base_url": "https://tieba.baidu.com",
            "api_url": "https://tieba.baidu.com/hottopic/browse/topicList",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "hupu": {
            "name": "虎扑",
            "type": "热榜",
            "description": "虎扑热门",
            "base_url": "https://bbs.hupu.com",
            "api_url": "https://bbs.hupu.com/topic",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        # 知识分享类
        "zhihu-daily": {
            "name": "知乎日报",
            "type": "日报",
            "description": "知乎日报",
            "base_url": "https://daily.zhihu.com",
            "api_url": "https://news-at.zhihu.com/api/4/news/latest",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "sspai": {
            "name": "少数派",
            "type": "热榜",
            "description": "少数派热门文章",
            "base_url": "https://sspai.com",
            "api_url": "https://sspai.com/api/v1/articles",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        # 娱乐类
        "douban-movie": {
            "name": "豆瓣电影",
            "type": "热榜",
            "description": "豆瓣电影热门",
            "base_url": "https://movie.douban.com",
            "api_url": "https://movie.douban.com/j/search_subjects",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            },
            "params": {"type": "movie", "tag": "热门", "sort": "recommend", "page_limit": 50}
        },
        
        "acfun": {
            "name": "AcFun",
            "type": "热榜",
            "description": "AcFun热门",
            "base_url": "https://www.acfun.cn",
            "api_url": "https://www.acfun.cn/rest/pc-direct/rank/channel",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        # 游戏类
        "lol": {
            "name": "英雄联盟",
            "type": "热榜",
            "description": "英雄联盟热门",
            "base_url": "https://lol.qq.com",
            "api_url": "https://apps.game.qq.com/cmc/cross",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "genshin": {
            "name": "原神",
            "type": "热榜",
            "description": "原神热门",
            "base_url": "https://ys.mihoyo.com",
            "api_url": "https://api-takumi.mihoyo.com/content_v2_user/app/194/getContentList",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        # 工具类
        "weread": {
            "name": "微信读书",
            "type": "热榜",
            "description": "微信读书热门",
            "base_url": "https://weread.qq.com",
            "api_url": "https://weread.qq.com/web/bookList",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        "history": {
            "name": "历史上的今天",
            "type": "历史",
            "description": "历史上的今天",
            "base_url": "https://www.todayonhistory.com",
            "api_url": "https://www.todayonhistory.com/api/list",
            "method": "GET",
            "headers": {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
        },
        
        # 以下平台将在后续版本中逐步添加完整配置
        "51cto": {"name": "51CTO", "type": "热榜", "description": "51CTO技术热榜", "available": False},
        "52pojie": {"name": "吾爱破解", "type": "热榜", "description": "吾爱破解热门", "available": False},
        "baidu": {"name": "百度", "type": "热榜", "description": "百度热点", "available": False},
        "coolapk": {"name": "酷安", "type": "热榜", "description": "酷安热门", "available": False},
        "csdn": {"name": "CSDN", "type": "热榜", "description": "CSDN技术热榜", "available": False},
        "dgtle": {"name": "数字尾巴", "type": "热榜", "description": "数字尾巴热门", "available": False},
        "douban-group": {"name": "豆瓣小组", "type": "热榜", "description": "豆瓣小组热门", "available": False},
        "earthquake": {"name": "地震信息", "type": "信息", "description": "地震信息", "available": False},
        "geekpark": {"name": "极客公园", "type": "热榜", "description": "极客公园热门", "available": False},
        "guokr": {"name": "果壳", "type": "热榜", "description": "果壳热门", "available": False},
        "hackernews": {"name": "Hacker News", "type": "热榜", "description": "Hacker News热门", "available": False},
        "hellogithub": {"name": "HelloGitHub", "type": "热榜", "description": "HelloGitHub热门", "available": False},
        "history": {"name": "历史上的今天", "type": "历史", "description": "历史上的今天", "available": False},
        "honkai": {"name": "崩坏3", "type": "热榜", "description": "崩坏3热门", "available": False},
        "hostloc": {"name": "Hostloc", "type": "热榜", "description": "Hostloc热门", "available": False},
        "huxiu": {"name": "虎嗅", "type": "热榜", "description": "虎嗅热门", "available": False},
        "ifanr": {"name": "爱范儿", "type": "热榜", "description": "爱范儿热门", "available": False},
        "ithome": {"name": "IT之家", "type": "热榜", "description": "IT之家热门", "available": False},
        "ithome-xijiayi": {"name": "IT之家西岐", "type": "热榜", "description": "IT之家西岐热门", "available": False},
        "jianshu": {"name": "简书", "type": "热榜", "description": "简书热门", "available": False},
        "kuaishou": {"name": "快手", "type": "热榜", "description": "快手热门", "available": False},
        "linuxdo": {"name": "Linux中国", "type": "热榜", "description": "Linux中国热门", "available": False},
        "miyoushe": {"name": "米游社", "type": "热榜", "description": "米游社热门", "available": False},
        "newsmth": {"name": "水木社区", "type": "热榜", "description": "水木社区热门", "available": False},
        "ngabbs": {"name": "NGA论坛", "type": "热榜", "description": "NGA论坛热门", "available": False},
        "nodeseek": {"name": "NodeSeek", "type": "热榜", "description": "NodeSeek热门", "available": False},
        "nytimes": {"name": "纽约时报", "type": "热榜", "description": "纽约时报热门", "available": False},
        "producthunt": {"name": "Product Hunt", "type": "热榜", "description": "Product Hunt热门", "available": False},
        "sina": {"name": "新浪", "type": "热榜", "description": "新浪热门", "available": False},
        "smzdm": {"name": "什么值得买", "type": "热榜", "description": "什么值得买热门", "available": False},
        "starrail": {"name": "崩坏星穹铁道", "type": "热榜", "description": "崩坏星穹铁道热门", "available": False},
        "thepaper": {"name": "澎湃新闻", "type": "热榜", "description": "澎湃新闻热门", "available": False},
        "weatheralarm": {"name": "天气预警", "type": "信息", "description": "天气预警信息", "available": False},
        "yystv": {"name": "游研社", "type": "热榜", "description": "游研社热门", "available": False}
    }
    
    @classmethod
    def get_platform(cls, platform: str) -> Dict[str, Any]:
        """获取平台配置"""
        return cls.PLATFORMS.get(platform, {})
    
    @classmethod
    def get_all_platforms(cls) -> Dict[str, Dict[str, Any]]:
        """获取所有平台配置"""
        return cls.PLATFORMS
    
    @classmethod
    def get_available_platforms(cls) -> Dict[str, Dict[str, Any]]:
        """获取可用平台配置"""
        return {k: v for k, v in cls.PLATFORMS.items() if v.get("available", True)}
    
    @classmethod
    def get_platform_names(cls) -> Dict[str, str]:
        """获取平台名称映射"""
        return {k: v["name"] for k, v in cls.PLATFORMS.items()}


# 平台实例
platform_config = PlatformConfig()